package book.shape;

/**
 * 长方形
 */
public class Rectangle extends PlaneGraphics {
    protected double length; // 长
    protected double width; // 宽

    /**
     * 长方形
     *
     * @param length 长
     * @param width  宽
     */
    public Rectangle(double length, double width) {
        super("长方形");
        if (length == width) {
            this.changeShape("正方形");
        }
        this.length = length;
        this.width = width;
    }

    /**
     * 正方形
     *
     * @param width 边长
     */
    public Rectangle(double width) {
        super("正方形");
        this.length = width;
        this.width = width;
    }

    /**
     * 无参数情况
     */
    public Rectangle() {
    }

    public double area() {
        return width * length;
    }
}
